Welcome to “Updating Deployed Applications.” After watching this video, you will be able to describe the common scenarios
of updating applications, update applications via IBM Cloud Console, and update applications via IBM Cloud CLI. Now suppose you develop a microservices-based
PetShop web application for your pet business, and you deploy each microservice as an
application within a code engine project. Your PetShop app receives a great
amount of web traffic volume, so you decide to migrate some of your
data from a SQL DB to a Non-SQL DB. Consequently, you develop and
build another container image for your new DB service and update your
Pets DB service based on the new image. In addition, you require some new
environment variables for your application and more computation resources
to handle the requests to your NoSQL DB. Code engine manages each revision of your
deployed application so you do not need to delete your application and deploy a new one. You can simply update the existing application, and the code engine will create
and manage a new revision for you. So, you have the following four common scenarios
for updating your code engine applications: update environment variables such
as database location or secret key; update application visibility, such as changing the URL of an application
from public to private or project-only; update your application's
image reference or GitHub repo; or update the runtime resources
of your application. Now like application deployments, you
can also update your application using the IBM Cloud Code Engine Console or CLI. If it is a simple update like
adding an environment variable, it's easier and faster to use
the well-designed console UI. But for more complex and precise application updates,
the Code Engine CLI may be more appropriate. The main command to perform all
app updates-related operations is "ibmcloud ce application update.” On your application console page, if you
click the Environment variables table, you can find all the environment variables. To add or update an environment variable, you
can click the "Add environment variable" button. Alternatively, if you prefer the command line
interface (IBM Cloud CLI), the main command to add or update an environment variable is
“ibmcloud ce app update” with two main arguments: the name of your application, and the name and value of your environment variable. Let’s see a quick example: First, add an environment
variable called `DB_HOST` with value `localhost` to the
‘pet_db_service’ application. The update command returns the message the
‘pet_db_service’ is updated to the latest version. To double-check if the environment was
added successfully, you can use the `app get` command to display the detailed
information of pet_db_service application. You can now see that the environment
variable DB_HOST is added as expected. Now when you deploy your application, it is assigned
with two types of URLs: internal and external. Internal URLs help to communicate with
other applications within your application. And external URLs can be public, external,
or IBM private network only. The selection of the type of URL defines
the visibility of your application. On your application console page, click the system Domain mappings tab to
update the visibility of your application. When No external system
domain mapping is selected, this application is not accessible
from the public internet, and network access is only possible from
components within this project (cluster-local). The cluster-local URL is displayed
when the option is selected. When private is selected, this application is accessible via the
IBM Cloud Virtual Private Endpoints. When public is selected, you can view the public
and the cluster-local URL for the application. Similarly, you can update
application visibility via CLI: The main command is still “ibmcloud ce app update” with two main arguments: the
name of your application and the visibility of your application. Let’s see a quick example: You first update the ‘pet_db_service’
application’s visibility to “private.” Then, if you get the app’s detailed
information, you should see two URLs. The external URL now contains a private subdomain which means now the pet_db_service can only
be accessed via IBM virtual private networks. Now, you can update the image reference
via Console UI as follows: On your application console
page, click the “Code” tab. Then specify the new image
reference for your application. On the CLI, the “ibmcloud ce app update” command has three arguments for
updating image references: the name of your application, the name and value of your image reference, and registry secret to access the
non-public container registry. Let’s see an example: Here you update the image reference to `us.icr.io/petshop/no_sql_pet_db_service`
with container registry to be `myregistry` If your application instances have very
long response time or very high CPU and memory usage, you can increase the
application’s runtime resources. To do so, go to your application
page and click the `Runtime` tab. Then you can update the CPU, memory, and ephemeral
storage of your instance as per your requirements. If you want your application to scale up or down, you can also update the scaling and
concurrency settings on the same UI. To update CPU or GPU via CLI, you will need to use the same “ibmcloud ce app update”
command with three main arguments: the name of your application, the amount of CPU set for the instance, and the amount of memory set for the instance. Let’s see our example. You increase each instance of `pet_db_service`
runtime resources to 2 CPUs and 16 GB memory. In this video, you learned that you can create a Cloud Engine application
either from a pushed container image or ask Cloud Engine to build the image
from a source code repository. And, you can select the UI with IBM
Cloud Console or command line interface with IBM Cloud CLI to perform the
deployment tasks as per your preference.